package com.ruoyi.web.controller.pssd;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pssd.domain.PsdDrug;
import com.ruoyi.pssd.domain.PsdPurchase;
import com.ruoyi.pssd.service.PsdExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/pssd/examine")
public class PsdExamineController extends BaseController {
    @Autowired
    private PsdExamineService psdExamineService;

    /**
     * 获取列表
     */
    @PreAuthorize("@ss.hasPermi('pssd:examine:list')")
    @GetMapping("/list")
    public TableDataInfo list() {
        startPage();
        List<PsdPurchase> list = psdExamineService.selectPurchaseDocuments();
        return getDataTable(list);
    }


    /*@PreAuthorize("@ss.hasPermi('pssd:purchase:edit')")
    @PutMapping(value = "/{purchaseId}")
    public AjaxResult getInfo(@PathVariable Long purchaseId,String status) {
        return toAjax(psdExamineService.updateStatus(purchaseId, status));
    }
*/
    @PreAuthorize("@ss.hasPermi('pssd:purchase:edit')")
    @Log(title = "状态信息", businessType = BusinessType.UPDATE)
    @PutMapping("/{ids}")
    public AjaxResult edit(@PathVariable Long[] ids) {
        return toAjax(psdExamineService.updatePurchaseById(ids));
    }

    @PreAuthorize("@ss.hasPermi('pssd:purchase:remove')")
    @Log(title = "删除药品信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{purchaseIds}")
    public AjaxResult remove(@PathVariable Long[] purchaseIds) {
        return toAjax(psdExamineService.deletePurchaseById(purchaseIds));
    }


}
